跳到主要内容

AddText

Adds a text to the specified position.

Syntax

expression.AddText(sText, sPosition);

expression - A variable that represents a ApiRange class.

Parameters

NameRequired/OptionalData typeDefaultDescription
sTextRequiredStringThe text that will be added.
sPositionOptionalstring"after"The position where the text will be added ("before" or "after" the range specified).

Returns

boolean

Example

This example adds a text to the specified position.

let doc = Api.GetDocument();
let paragraph = doc.GetElement(0);
paragraph.AddText("Document");
let range = doc.GetRange(0, 7);
range.AddText("ONLYOFFICE ", "before");
range.AddText(" Builder", "after");